<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery" >
        
        <a-row :gutter="24" style="padding-top: 30px">
          <a-col :md="6" :sm="8">
            <a-form-item label="生产订单号" :label-col="{ span:6 }" :wrapper-col="{ span: 15 }">
              <a-input placeholder="生产订单号" v-model="queryParam.ipoNo"></a-input>
            </a-form-item>
            
          </a-col>
          <a-col :md="18" :sm="16" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
               <a-button type="primary" @click="showOrClose" icon="search" style='margin-left: 10px;'>高级查询</a-button>
               <a-button type="primary" icon="download" @click="handleExportXls('eip_work_order')" style='margin-left: 10px;'>导出</a-button>
            </span>
          </a-col>
         
        </a-row>
      </a-form>

    </div>
    <a-row v-if="show" style="padding-top: 30px">
      
      <a-col :md="6" :sm="8">
       <a-form-item label="工单号" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
         <a-input placeholder="工单号" v-model="queryParam.woNo"></a-input>
       </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="物料描述" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
          <a-input placeholder="物料描述" v-model="queryParam.materialsDescription"></a-input>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="工艺路线编码" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
          <a-input placeholder="工艺路线编码" v-model="queryParam.processRouteNo"></a-input>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="计划开始日期" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
          <a-date-picker v-model="queryParam.planStartDate"/>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="计划完成时间" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
          <a-date-picker v-model="queryParam.planFinishDate"/>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8" >
        <a-form-item label="组织架构" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
           <a-select
               v-model="value"
               mode="multiple"
               style="width: 100%"
               placeholder="select one country"
               option-label-prop="label"
             >
               <a-select-option value="平高电器" label="平高电器">
                  平高电器
               </a-select-option>
               <a-select-option value="组合电器" label="组合电器">
                 <span role="img" aria-label="组合电器">
                   平高
                 </span>
                 组合电器
               </a-select-option>
               <a-select-option value="断路器" label="断路器">
                 <span role="img" aria-label="断路器">
                   平高
                 </span>
                断路器
               </a-select-option>
               <a-select-option value="平芝" label="平芝">
                 平芝
               </a-select-option>
             </a-select>
        </a-form-item>
      </a-col>
    </a-row>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="puid"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a @click="toBd(record)">关联生产报工</a>
          <!--<a-dropdown>-->
            <!--<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
            <!--<a-menu slot="overlay">-->
              <!--<a-menu-item>-->
                <!--<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
                  <!--<a>删除</a>-->
                <!--</a-popconfirm>-->
              <!--</a-menu-item>-->
            <!--</a-menu>-->
          <!--</a-dropdown>-->
        </span>

      </a-table>
    </div>

    <eipWorkOrder-modal ref="modalForm" @ok="modalFormOk"></eipWorkOrder-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import EipWorkOrderModal from './modules/EipWorkOrderModal'
  export default {
    name: "EipWorkOrderList",
    mixins:[JeecgListMixin],
    components: {
      EipWorkOrderModal
    },
    data () {
      return {
         value: ['平高电器'],
        description: 'eip_work_order管理页面',
        show:false,
        orgName1:"",
        orgName2:"",
        org1:"",
        org2:"",
        // 表头
        columns: [
          {
            title:'采购方总部编码',
            align:"center",
            dataIndex: 'purchaserHqCode'
          },
          {
            title:'供应商编码',
            align:"center",
            dataIndex: 'supplierCode'
          },
          {
            title:'供应商名称',
            align:"center",
            dataIndex: 'supplierName'
          },
          {
            title:'生产工单编码',
            align:"center",
            dataIndex: 'woNo'
          },
          {
            title:'供应商生产订单编号',
            align:"center",
            dataIndex: 'ipoNo'
          },
          {
            title:'品类编码',
            align:"center",
            dataIndex: 'categoryCode'
          },
          {
            title:'种类编码',
            align:"center",
            dataIndex: 'subclassCode'
          },
          {
            title:'厂家物料编码',
            align:"center",
            dataIndex: 'materialsCode'
          },
          {
            title:'厂家物料描述',
            align:"center",
            dataIndex: 'materialsDescription'
          },
          {
            title:'生产数量',
            align:"center",
            dataIndex: 'amount'
          },
          {
            title:'计量单位',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title:'计划开始日期',
            align:"center",
            dataIndex: 'planStartDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'计划完成日期',
            align:"center",
            dataIndex: 'planFinishDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际开始日期',
            align:"center",
            dataIndex: 'actualStartDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际完成日期',
            align:"center",
            dataIndex: 'actualFinishDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'工单状态',
            align:"center",
            dataIndex: 'woStatus'
          },
          {
            title:'工艺路线编码',
            align:"center",
            dataIndex: 'processRouteno'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/eipWorkOrder/selectForList?ipoNo="+this.$route.params.ipoNo,
          // delete: "/pg/eipWorkOrder/delete",
          // deleteBatch: "/pg/eipWorkOrder/deleteBatch",
          // exportXlsUrl: "/pg/eipWorkOrder/exportXls",
          importExcelUrl: "/eipWorkOrder/importExcel",
        },
        dictOptions:{
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      showOrClose(){
        this.show = !this.show;
      },
      toBd(record){
        this.$router.push({ name: 'bg-bgList',params:{woNo:record.woNo}})
      }
    },
    watch: {
       value(val) {
         console.log(`selected:`, val);
       },
     },
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>